﻿Public Class CategoriesDAL
    Inherits SQLiteDatabase
    Implements InterfaceDb
    Public Sub New(ByVal inputFile As String)
        MyBase.New(inputFile)
    End Sub
    ''' <summary>
    ''' p: 10
    ''' b 
    '''      byte:1 null
    '''      byte:2 10
    '''      byte:3 text length
    '''      byte:4 Content
    '''      byte:5 null
    '''      byte:6 null
    ''' c: thời gian tạo bản ghi (tính bằng hàm Now2Unix - "modDateTimeUTC")
    ''' d: bị xóa hay chưa (0|1)
    ''' e: thời gian sửa bản ghi (tính bằng hàm Now2Unix -"modDateTimeUTC")
    ''' r: trường dự trữ, không dùng
    ''' i,j,k,l,m: trường nguyên phục vụ sắp xếp
    ''' s,t,u,v,w: trường text thứ hai, được mã hóa 64 bit
    ''' x,y,z: cờ
    ''' g,h: trường nguyên để nhóm dữ liệu thành các mụcs
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks>
    ''' Optional a As Currency = 0, _
    ''' Optional b As String = "", Optional BB As String = "", Optional f As String = "", _
    ''' Optional c As Long = 0, Optional D As Byte = 0, Optional e As Long = 0, Optional r As Long = 0, _
    ''' Optional p As Byte = 0, Optional q As Byte = 0, _
    ''' Optional i As Currency = 0, Optional j As Long = 0, Optional k As Long = 0, Optional L As Long = 0, Optional m As Long = 0, _
    ''' Optional s As String = "", Optional t As String = "", Optional u As String = "", Optional v As String = "", Optional w As String = "", _
    ''' Optional x As Byte = 0, Optional y As Byte = 0, Optional z As Byte = 0, _
    ''' Optional g As Integer = 0, Optional H As Integer = 0, _
    ''' Optional bTransaction As Boolean = True, _
    ''' Optional bExec As Boolean = True, _
    ''' Optional bReplace As Boolean = True, _
    ''' Optional sDb As String = ""
    ''' </remarks>
    Public Overloads Function Insert(ByVal ctrCategory As String)
        Dim data As New Dictionary(Of String, String)
        data.Add("p", "10")             ' primary section 
        data.Add("c", DateTime.Today)   ' time created 
        data.Add("e", DateTime.Today)   ' time edited 
        data.Add("b", ctrCategory)      ' encrypted and 64-encoded record 
        data.Add("f", ctrCategory)      ' ???
        data.Add("x", "1")              ' ???
        Return MyBase.Insert(data)
    End Function

    Public Overloads Function Update(ByVal id As Integer, ByVal ctrCategory As String)
        Dim data As New Dictionary(Of String, String)
        Dim where As String = " a=" & id
        data.Add("e", DateTime.Today)   ' time edited 
        data.Add("b", ctrCategory)      ' encrypted and 64-encoded record 
        data.Add("f", ctrCategory)      ' ???

        Return MyBase.Update(data, where)
    End Function




End Class
